﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace DoAnPhatTrienPhanMem.Controllers
{
    public class MenuController : Controller
    {
        //
        // GET: /Menu/


        public class CustomizeMenu
        {
            public String Controller;
            public String Action;
            public String Param;

            public CustomizeMenu()
            {
                Controller = "";
                Action = "";
                Param = "";
            }
        }

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult HomePage()
        {
            return View();
        }

        public ActionResult IndexPage()
        {
            var Ctrl = Request["Controller"];
            var Act = Request["Action"];
            var ID = Request["ID"];
            var listMenu = new CustomizeMenu[1];
            listMenu[0].Controller = Ctrl;
            listMenu[0].Action = "AddOrEdit";
            ViewData["ListMenu"] = listMenu;
            return View();
        }

        public ActionResult AddOrEditPage()
        {
            var Ctrl = Request["Controller"];
            var Act = Request["Action"];
            return View();
        }

        public ActionResult DetailsPage()
        {
            var Ctrl = Request["Controller"];
            var Act = Request["Action"];
            CustomizeMenu[] listMenu;
            listMenu = new CustomizeMenu[2];
            listMenu[0].Controller = "";
            ViewData["ListMenu"] = listMenu;
            return View();
        }

        public ActionResult DefaultMenu()
        {
            var Ctrl = Request["Controller"];
            var Act = Request["Action"];
            var ID = "";
            var IDvien = "";
            if (Request.Params.AllKeys.Contains("ID"))
            {
                ID = Request["ID"];
            }
            if (Request.Params.AllKeys.Contains("IDvien"))
            {
                IDvien = Request["IDvien"];
                ViewData["IDvien"] = IDvien;
            }
            //CustomizeMenu[] listMenu;
            //if (Act == "Index")
            //{
            //    listMenu = new CustomizeMenu[1];
            //    listMenu[0].Controller = Ctrl;
            //    listMenu[0].Action = "AddOrEdit";
            //}
            //else if (Act == "AddOrEdit")
            //{
            //    listMenu = new CustomizeMenu[1];
            //}
            //else if (Act == "Details")
            //{
            //    var ID = Request["ID"];
            //    listMenu = new CustomizeMenu[2];
            //    listMenu[0].Controller = Ctrl;
            //    listMenu[0].Action = "AddOrEdit";
            //    listMenu[0].Param = ID;
            //    listMenu[1].Controller = Ctrl;
            //    listMenu[1].Action = "Delete";
            //    listMenu[1].Param = ID;
            //}
            //else listMenu = new CustomizeMenu[1];
            //ViewData["ListMenu"] = listMenu;
            ViewData["Controller"] = Ctrl;
            ViewData["Action"] = Act;
            ViewData["ID"] = ID;

            return View();
        }

        public ActionResult CustomPage()
        {
            var Ctrl = Request["Controller"];
            var Act = Request["Action"];
            var ID = Request["ID"];
            ViewData["Controller"] = Ctrl;
            ViewData["Action"] = Act;
            ViewData["ID"] = ID;
            CustomizeMenu[] listMenu;
            listMenu = new CustomizeMenu[1];
            listMenu[0].Controller = "";
            ViewData["ListMenu"] = listMenu;
            return View();
        }

        public ActionResult VienDetails()
        {
            var Ctrl = Request["Controller"];
            var Act = Request["Action"];
            var ID = Request["ID"];
            ViewData["Controller"] = Ctrl;
            ViewData["Action"] = Act;
            ViewData["ID"] = ID;
            return View();
        }
    }
}
